<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Dettagli Cane</title>
              
        <script type="text/javascript" src="../Scripts/jquery-1.9.0.js"></script>     
           
        <link rel="stylesheet" type="text/css" href="../Style/siteStyle.css">
        <link rel="stylesheet" type="text/css" href="../Style/pluginStyle.css"> 
        
        <script>
			$(document).ready(function() {
			    $("#content div.isTab").hide(); // Initially hide all content
			    $("#tabs li:first").attr("id","current"); // Activate first tab
			    $("#content div:first").fadeIn(); // Show first tab content
			    			    
			    $('#tabs a').click(function(e) {
			        e.preventDefault();
			        if ($(this).closest("li").attr("id") == "current"){ //detection for current tab
			         return       
			        }
			        else{             
			        $("#content div.isTab").hide(); //Hide all content
			        $("#tabs li").attr("id",""); //Reset id's
			        $(this).parent().attr("id","current"); // Activate this
			        $('#' + $(this).attr('name')).fadeIn(); // Show content for current tab
			        }
			    });
			});
		</script>   
	  
        <?php
            include '../config.php';
            include '../db/volontariCani.php';
            include '../db/configurazioni.php';
        ?>
         <?php
        	
        	
            if(isset($_REQUEST['Cancella']))            
            {
            	 $esami = new volontariCani();
                 $idEsame=$_REQUEST['Cancella'];                 
                 $esami->deleteEsameCane($idEsame);                                 
            }
        ?> 
    </head>
    <body>
        
        <div class="container">        		                  
            <!-- header -->
            <?php include '../Sections/header.html'; ?>
            <div>                               
                <!-- menu di sinistra -->
                <?php include '../Sections/leftMenu.html'; ?>
                <!-- contenuto -->
                
                <div class="mainContent">
                <form action="" method="post">               
                <ul id="tabs">
    				<li><a href="#" name="tab1">Dati</a></li>
    				<li><a href="#" name="tab2">Esami</a></li>    				
				</ul>
				 <?php
                            
                    	 $cani = new volontariCani();
                         $idCane="";
                         if(isset($_GET['id_cane']))
                         {
                              $idCane=$_GET['id_cane'];                 

                              $result = $cani->getCane($idCane);
                              
                              $cane = mysql_fetch_array($result);
                         ?>
				<div id="content"> 
                <div id="tab1" class="isTab">                   
                    
                    <h2><?php echo $cane[0]?></h2>
                    <div class="errore"><label id="errore"></label></div>                  
                     
				           
                    <div class="datiVolontario">
                        <div><label>Nome:&nbsp;&nbsp;</label><?php echo $cane[0]?></div>
                        <div><label>Numero chip:&nbsp;&nbsp;</label><?php echo $cane[1]?></div>
                        <div><label>Razza:&nbsp;&nbsp;</label><?php echo $cane[3]?></div>
                        <div><label>Data nascita:&nbsp;&nbsp;</label><?php echo $cane[7]?></div>                                                
                    </div>
                    <div class="btnDettagliModifica">
                      <button type="button" name="Modifica" 
                              title="Modifica dati volontario"
                              value="<?php echo $idCane; ?>" 
                              onclick="window.location.href = 'DatiCane.php?id_cane=<?php echo $idCane; ?>'">  
                              <img src="../Style/Images/modify_32.png" alt="Elimina"/>    
                      </button>
                    </div>
                    <div style="clear: both"></div>
                    
                    
                	</div>
                	<?php
					$result = $cani->getEsamiCane($idCane);
                	if(mysql_num_rows ( $result))
                	{?>
                	<div id="tab2" class="isTab">
                	  
	                    <h2><?php echo $cane[0]?></h2>
	                    <div class="errore"><label id="errore"></label></div>    
	                    	<div class="list">                   
                        		<div style="float: left;"><h3>Lista Esami Cane</h3></div>
                        		<div style="text-align: right; float: right;">
                        			<a href="DatiEsame.php?cane=<?php echo $cane[0]?>&id_cane=<?php echo $idCane; ?>">
                        				<img src="../Style/Images/add_48.png" alt="Aggiungi esame" title="Aggiungi esame"/>                        				
                        			</a>
                        		</div>
                        		<div style="clear: both;"></div>
		                        <table cellspacing="0" cellpadding="4px">
		                            <tr>
		                                <th>Nome</th>
		                                <th>Ente</th>
		                                <th>Descrizione</th>
		                                <th>Data Esame</th>
		                                <th>Data Scadenza</th>
		                                <th>Luogo</th>
										<th>Voto</th>		                                
										<th>Modifica</th>
		                                <th>Elimina</th>                                
		                            </tr>
		                        <?php
		                    
		                    while ($row = mysql_fetch_assoc($result)) {
		                        ?>
		                            <tr>                                
		                                <td>
		                                    <?php echo $row['nome']; ?>		                                    
		                                </td>
		                                <td>
		                                    <?php echo $row['ente']; ?>
		                                </td>
		                                <td>
		                                    <?php echo $row['descrizione']; ?>
		                                </td>
		                                 <td>
		                                    <?php echo $row['dataEsame']; ?>
		                                </td>
		                                <td>
		                                    <?php echo $row['dataScadenza']; ?>
		                                </td>
		                                <td>
		                                    <?php echo $row['luogo']; ?>
		                                </td>
		                                <td>
		                                    <?php echo $row['voto']; ?>
		                                </td>
		                                <td style="text-align: center">
		                                    <button type="button" name="Modifica" 
		                                    title="Modifica dati esame"
		                                    value="<?php echo $row['id']; ?>" 
		                                    onclick="window.location.href = 'DatiEsame.php?id_esame=<?php echo $row['id']?>&cane=<?php echo $cane[0]?>&id_cane=<?php echo $idCane; ?>'">  
		                                        <img src="../Style/Images/modify_20.png" alt="Modifica"/>    
		                                    </button>
		                                </td>
		                                <td style="text-align: center">
		                                    <button type="submit" name="Cancella" 
		                                    title="Elimina dati esame"
		                                    value="<?php echo $row['id']; ?>" 
		                                    onclick="return confirm('Sei sicuro di voler rimuovere esame <?php echo $row['nome']; ?> del <?php echo $row['dataEsame']; ?>');">  
		                                        <img src="../Style/Images/delete_20.png" alt="Elimina"/>    
		                                    </button>
		                                </td>
		                                
		                            </tr>
		                               
		                <?php
		                    }
		
		                    ?> 
		                    
		                        </table>                        
                		    </div>
	                    </div>
	                    <?php }?>
                	</div>
                	<?php }
                    else {
                        echo 'Cane non trovato.';
                    }
                    ?>
                	</form>     
                </div>
                <div style="clear:both"></div>     
                           
            </div>
        </div>
        
    </body>
</html>
